package com.atguigu.utils;

import java.sql.Connection;
import java.sql.SQLException;

/**
 * JDBC连接
 *
 * Project: DXXM
 * Package: com.atguigu
 * Version: 1.0
 * <p>
 * Created by  WangJX  on 2020/2/20 22:44
 */
public class JDBCCacheBean {
    private static Connection conn = null;
    private JDBCCacheBean(){}
    public static Connection getInstance(){
        try {
            if(conn == null || conn.isClosed() || conn.isValid(3)){
                conn = JDBCUtil.getConnection();
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return conn;
    }
}
